package com.ueboot.weishop.admin.batch.log;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.stereotype.Component;

@Component
public class JobExecutionLogListener implements JobExecutionListener {

	private Logger logger = LoggerFactory.getLogger(this.getClass());

	private String jobName;

	public JobExecutionLogListener() {
	}

	public JobExecutionLogListener(String jobName){
		this.jobName = jobName;
	}

	public void beforeJob(JobExecution jobExecution) {
		logger.info("####{}任务开始执行,params:{}",jobName,jobExecution.getJobParameters().toString());
	}

	public void afterJob(JobExecution jobExecution) {
		logger.info("####{}任务执行结束",jobName);
	}


	public String getJobName() {
		return jobName;
	}

	public void setJobName(String jobName) {
		this.jobName = jobName;
	}
}
